import request from "@/utils/request";

enum API {
  //获取某一个三级分类下  已有的全部SPU数据
  spuList = "/admin/product/",
  //获取全部品牌的数据
  allTradeMark = "/admin/product/baseTrademark/getTrademarkList",
  //获取某一个已有的SPU下全部照片墙的数据
  spuImageList = "/admin/product/spuImageList/",
  //获取某一个已有的SPU下全部的销售属性与属性值
  spuSaleAttr = "/admin/product/spuSaleAttrList/",
  //获取全部的SPU的销售属性[一共就三个]
  allSaleAttr = "/admin/product/baseSaleAttrList",
  //添加一个新增的SPU
  addSpu = "/admin/product/saveSpuInfo",
  //修改已有的SPU
  updateSpu = "/admin/product/updateSpuInfo",
  //获取全部平台属性接口
  attrList = "/admin/product/attrInfoList/",
  //添加SKU的接口地址
  addSku="/admin/product/saveSkuInfo",
  //sku列表的数据
  skuList="/admin/product/findBySpuId/",
  //删除已有SPU
  removeSpu="/admin/product/deleteSpu/"
}

export const reqHasSpuList = (
  page: number,
  limit: number,
  category3Id: string | number
) => request.get(API.spuList + `${page}/${limit}?category3Id=${category3Id}`);

//获取全部品牌的接口数据
export const reqAllTrademarkList = () => request.get(API.allTradeMark);
//获取相应已有的SPU照片墙的数据
export const reqSpuImageList = (spuId: number) =>
  request.get(API.spuImageList + spuId);
//获取某一个已有的SPU下全部的销售属性与属性值
export const reqSpuSaleAttrList = (spuId: number) =>
  request.get(API.spuSaleAttr + spuId);
//获取全部的SPU的销售属性[一共就三个]
export const reqAllSaleAttr = () => request.get(API.allSaleAttr);
//添加与修改SPU的接口函数
export const reqAddOrUpdateSpu = (data: any) => {
  if (data.id) {
    return request.post(API.updateSpu, data);
  } else {
    return request.post(API.addSpu, data);
  }
};
//获取平台属性的接口
export const reqAttrList = (
  category1Id: number | string,
  category2Id: number | string,
  category3Id: number | string
) => request.get(API.attrList + `${category1Id}/${category2Id}/${category3Id}`);
//添加SKU的接口函数
export const reqAddSku = (data:any)=>request.post(API.addSku,data);
//获取某一个已有的SPU下全部sku列表
export const reqSkuList = (spuId:number)=>request.get(API.skuList+spuId);
//删除已有的SPU
export const reqRemoveSpu = (spuId:number)=>request.delete(API.removeSpu+spuId);